package com.zito.health.controller;

/**
 * Created by Administrator on 2019/11/17.
 */

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zito.health.common.enums.ResultCode;
import com.zito.health.common.result.PlatformResult;
import com.zito.health.entity.ItemExpertDeclare;
import com.zito.health.entity.ItemScoringStandard;
import com.zito.health.service.ItemExpertDeclareService;
import com.zito.health.service.ItemScoringStandardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 项目专家评审,项目评分标准
 */
@Slf4j
@RestController
@RequestMapping("/item/scoringStandard")
public class ItemScoringStandardController {

    @Autowired
    private ItemScoringStandardService itemScoringStandardService;

    /**
     * 查询项目评分标准
     * @return
     */
    @PostMapping("/list")
    public PlatformResult list(){
        List<ItemScoringStandard> list = itemScoringStandardService.query(null);
        JSONArray array1 = new JSONArray();
        JSONArray array2 = new JSONArray();
        JSONArray array3 = new JSONArray();
        JSONArray array4 = new JSONArray();
        for(ItemScoringStandard item:list){
            switch (item.getNorm()){
                case 1:
                    array1.add(item);
                    break;
                case 2:
                    array2.add(item);
                    break;
                case 3:
                    array3.add(item);
                    break;
                case 4:
                    array4.add(item);
                    break;
            }
        }
        JSONObject json = new JSONObject();
        json.put("a",array1);
        json.put("b",array2);
        json.put("c",array3);
        json.put("d",array4);
        return  PlatformResult.success(json);
    }

}
